package org.ajc.base.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.context.annotation.Configuration;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Configuration
public class AjaxResult {

    private Boolean success;
    private Object data;
    private String  msg;

    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setMsg("操作成功啦~");
        return ajaxResult;
    }
    public static AjaxResult success(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(true);
        ajaxResult.setMsg("操作成功啦~");
        ajaxResult.setData(data);
        return ajaxResult;
    }
    public static AjaxResult error(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg("网络异常~"+msg);
        return ajaxResult;
    }
    public static AjaxResult error(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg("网络异常~");
        return ajaxResult;
    }
    public static AjaxResult query(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setSuccess(false);
        ajaxResult.setMsg("输入用户有误，系统不存在该用户");
        ajaxResult.setData(data);
        return ajaxResult;
    }
}
